<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>源码教学</title>
<link rel="stylesheet" type="text/css" href="<%=basePath %>/admin/css/easyui.css">
<link rel="stylesheet" type="text/css" href="<%=basePath %>/admin/css/icon.css">
<script type="text/javascript" src="<%=basePath %>/admin/js/jquery-1.7.1.js"></script>
<script type="text/javascript" src="<%=basePath %>/admin/js/jquery.easyui.min.js"></script>
<script type="text/javascript" language="javascript" src="<%=basePath %>/admin/js/commom.js"></script>
<script type="text/javascript" language="javascript" src="<%=basePath %>/admin/js/operate.js"></script>
<link rel="stylesheet" href="<%=basePath %>/admin/kindeditor/themes/default/default.css" />
<script charset="utf-8" src="<%=basePath %>/admin/kindeditor/kindeditor.js"></script>
<script charset="utf-8" src="<%=basePath %>/admin/kindeditor/lang/zh_CN.js"></script>
<script type="text/javascript" src="<%=basePath %>/admin/kindeditor/plugins/code/brush.js"></script>
<link type="text/css" rel="stylesheet" href="<%=basePath %>/admin/kindeditor/plugins/code/shCore.css"/>
<link type="text/css" rel="stylesheet" href="<%=basePath %>/admin/kindeditor/plugins/code/shThemeDefault.css"/>
<script type="text/javascript">
	$(document).ready(
			function() {
		 	dataGridInfo("code_data", "/admin/soundcode/showCodes", "",
						"toolbar"); 
		 	$('#code_data').datagrid({  
		 		onDblClickRow:function(){
		 			editCode() ;
		 		}
			});  
		 	var p = $('#code_data').datagrid('getPager');  
			$(p).pagination({  
			    pageSize: 10,//每页显示的记录条数，默认为10  
			    pageList: [5,10,15],//可以设置每页记录条数的列表  
			    beforePageText: '第',//页数文本框前显示的汉字  
			    afterPageText: '页    共 {pages} 页',  
			    displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录',  
			});  
			});
	var editor1;//创建在线编辑器
	KindEditor.ready(function(K) {
		editor1 = K.create('textarea[name="soundcode.value"]', {
			cssPath : ['/admin/kindeditor/plugins/code/code.css'],
			uploadJson : '/admin/kindeditor/jsp/upload_json.jsp',
			fileManagerJson : '/admin/kindeditor/jsp/file_manager_json.jsp',
			allowFileManager : true,
			items : ['bold', 'italic', 'underline', 'strikethrough', 'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'formatblock', 'insertorderedlist', 'insertunorderedlist', '|','forecolor',
		 'hilitecolor', 'fontname', 'fontsize', '|','code','link', 'unlink', 'emoticons', 'image', 'table', '|', 'fullscreen', 'source']
		});
	});
	
	function editCode() {
		var row = $('#code_data').datagrid('getSelected');
		if (row) {
			$('#article_win').dialog('open').dialog('setTitle', '修改');
			$("#title").get(0).value = row.title;
			$("#author").get(0).value = row.author;
			$("#codeId").get(0).value = row.id;
			editor1.html(row.value);
			$("#articleForm").attr("action", "/admin/soundcode/updateCode");
		}
	}
	function newCode(){
		$("#article_win").window('open');
		$("#articleForm").attr("action", "/admin/soundcode/saveCode");
		$("#articleForm").form('clear');
		editor1.html('');
	}
</script>
</head>
<body>
	<div class="easyui-panel" data-options="fit:true" style='border: none'>
		<div class="easyui-layout" data-options="fit:true"
			style='border: none'>
			<div id='sss' data-options="region:'center'" style='border: none'>
				<table style='border: 1px solid red' id="code_data"
					class="easyui-datagrid">
					<thead>
						<tr>
							<th data-options="field:'id',width:100,align:'center',hidden:true">ID</th>
							<th data-options="field:'title',width:100,align:'center'">标题</th>
							<th data-options="field:'author',width:160,align:'center'">作者</th>
							<th data-options="field:'createDate',width:160,align:'center'">更新时间</th>
						</tr>
					</thead>
				</table>
				<div id="toolbar">
				<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newCode()">添加</a>
					<a href="javascript:void(0)" class="easyui-linkbutton"
						iconCls="icon-edit" plain="true" onclick="editCode()">修改</a>
					<a href="javascript:void(0)" class="easyui-linkbutton"
						iconCls="icon-remove" plain="true"
						onclick="destroyModel('code_data','删除','/admin/soundcode/deleteCode')">删除</a>
				</div>

				<div id="article_win" class="easyui-window" title="文章添加" data-options="modal:true,closed:true,maximized:true" style="width:800px;height:500px">
   			<form id='articleForm' name="articleForm" method="post" >
		<table border="0" width="80%" >
			<tr>
				<td align="center">标题：</td>
				<td><input class="easyui-validatebox"   name='soundcode.title' id='title'/>
					<input name='soundcode.id' id='codeId' type='hidden'/>
				</td>
			</tr>
			<tr>
				<td align="center">作者：</td>
				<td><input type='text' name='soundcode.author'    id='author'/></td>
			</tr>
			<tr>
			<td align="center">内容：</td>
				<td colspan="1" align="left"><textarea  id='info' name="soundcode.value" cols="100" rows="8" style="width:700px;height:280px;"> </textarea>
				</td>
			</tr>
			<tr>
			<td align="center" colspan="2" >
			<br/>
				<input type='submit' value='提交' style='margin-right:150px'><!-- (提交快捷键: Ctrl + Enter) -->
			</td>
			</tr>
		</table>
	</form>
   	</div>
				<div id="dlg-buttons">
					 <a
						href="javascript:void(0)" class="easyui-linkbutton"
						iconCls="icon-cancel"
						onclick="javascript:$('#dlg').dialog('close')">取消</a>
				</div>
			</div>
		</div>
	</div>
</body>
</html>